/*
 * Copyright (C) Francisco Morero Peyrona. All rights reserved.
 *
 * This software is published under the terms of Open Source
 * License version 1.1, a copy of which has been included with 
 * this distribution in the License.txt file.
 */

package jdbcmanager.swing.help;

import java.util.*;

import java.awt.*;
import javax.swing.*;

import jdbcmanager.swing.table.*;

/**
 * Creates System Information JPanel.<br>
 * It shows all system properties, JVM memory usage and a button to invoke the garbage collector.
 *
 * @author Francisco Morero
 */

final class SystemPanel extends JPanel
{
   private JxTableMap tblProperties = new JxTableMap();

   //-------------------------------------------------------------------------//

   /**
    * Argument zero class constructor
    */
   SystemPanel()
   {
      fillTable();
      
      setLayout( new BorderLayout() );
      add( new JScrollPane( tblProperties), BorderLayout.CENTER );
   }

   void fillTable()
   {
       javax.swing.SwingUtilities.invokeLater( new Runnable()
       {
           public void run()
           {
               Properties pp  = System.getProperties();
               HashMap    map = new HashMap( pp.size() );
    
               for( Enumeration e = pp.propertyNames(); e.hasMoreElements(); )
               {
                  String sKey = (String) e.nextElement();
                   
                  map.put( sKey, pp.getProperty( sKey ) );
               }
    
               SystemPanel.this.tblProperties.setAutoResizeMode( JTable.AUTO_RESIZE_ALL_COLUMNS );
               SystemPanel.this.tblProperties.setData( map );
           }
       } );
   }
}